package cn.wujiangbo.controller;

import cn.wujiangbo.annotation.IgnoreAuth;
import cn.wujiangbo.controller.base.BaseController;
import cn.wujiangbo.result.JSONResult;
import cn.wujiangbo.service.system.impl.FileServiceLocalImpl;
import cn.wujiangbo.service.system.impl.FileServiceOssImpl;
import cn.wujiangbo.vo.UploadFileVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;

/**
 * <p>文件处理类</p>
 *
 * @Author 波波老师(weixin:javabobo0513)
 */
@RestController
@RequestMapping("/file")
@Slf4j
public class FileController extends BaseController {

    @Resource
    private FileServiceOssImpl fileService;

    /**
     * 上传文件
     * @param multipartFile 文件对象
     * @return JSONResult
     */
    @PostMapping("/uploadImageCommon")
    @IgnoreAuth
    public JSONResult uploadTanhuapingju(@RequestParam("fileName") MultipartFile multipartFile) {
        UploadFileVo uploadFileVo = fileService.uploadFile(multipartFile, "EasyJavaTemplateTest/tuiguang");
        return JSONResult.success(uploadFileVo);
    }

}
